# -*- coding: utf-8 -*-
# @Time : 2021/7/2 10:04
# @Author : feimaotuiya
# @File : page_front_login.py
# @Project : seleniumGitee
from selenium.webdriver.common.by import By


class PageEcshopFrontLogin():
    # 前台登录
    def __init__(self, driver):
        self.driver = driver
        # 元素定位符
        self.loc_front_login_username = (By.NAME, "username")
        self.loc_front_login_password = (By.NAME, "password")
        self.loc_front_login_submit = (By.NAME, "submit")
        self.loc_front_login_assert = (By.XPATH, '//font[@id="ECS_MEMBERZONE"]/a[1]')

    def front_login_username(self, username):  # 输入用户名
        self.driver.find_element(*self.loc_front_login_username).send_keys(username)

    def front_login_password(self, password):  # 输入密码
        self.driver.find_element(*self.loc_front_login_password).send_keys(password)

    def front_login_submit(self):  # 点击提交
        self.driver.find_element(*self.loc_front_login_submit).click()

    def front_login_assert(self):  # 断言
        actual = self.driver.find_element(*self.loc_front_login_assert).text
        return actual

    def front_login(self, username, password):
        self.front_login_username(username)
        self.front_login_password(password)
        self.front_login_submit()
        actual = self.front_login_assert()
        return actual
